package com.kuaiditu.assistant.ui.main;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.kuaiditu.assistant.R;
import com.kuaiditu.assistant.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class MyTaskFragment extends BaseFragment {

    public static final String TAG = "MyTaskFragment";

    private ViewPager mPageTask;

    private TabLayout mTaber;

    TaskPageAdapter mTaskPageAdapter;



    @Override
    public void initInjector() {

    }

    @Override
    public int initContentView() {
        return R.layout.fragment_my_task;
    }

    @Override
    public void getBundle(Bundle bundle) {

    }

    @Override
    public void initUI(View v) {
        mTaber = (TabLayout) v.findViewById(R.id.taber);
        mPageTask = (ViewPager) v.findViewById(R.id.page_task);
        mPageTask.setAdapter(mTaskPageAdapter = new TaskPageAdapter());

        mTaber.setupWithViewPager(mPageTask);




    }

    @Override
    public void initData() {

    }



    private class TaskPageAdapter extends FragmentPagerAdapter {

        List<Fragment> mFragments = new ArrayList<>();

        public TaskPageAdapter() {
            super( getChildFragmentManager());
            mFragments.add(new AwaitTaskFragment());
            mFragments.add(new CompleteTaskFragment());

        }

        @Override
        public Fragment getItem(int position) {
            return mFragments.get(position);
        }

        @Override
        public int getCount() {
            return mFragments.size();
        }


        @Override
        public CharSequence getPageTitle(int position) {
            return ((BaseFragment) mFragments.get(position)).getTitle();
        }
    }


}
